package book;  //书架的包


public class Book {
    private String name;         //书名
    private String author;       //作者
    private int price;           //价格
    private String type;         //类型
    private boolean isBorrowed;  //借阅状态

    //构造方法
    public Book(String name, String author, int price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    //访问方法
    public String getName() {
        return name;
    }

    public String getAuthor() {
        return author;
    }

    public int getPrice() {
        return price;
    }

    public String getType() {
        return type;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public void setType(String type) {
        this.type = type;
    }

    //获得借阅状态的访问方法
    public boolean isBorrowed() {
        return isBorrowed;
    }

    //设置借阅状态的访问方法
    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    //重写toString方法

    @Override
    public String toString() {
        return "Book{" +
                "书名：" + name  +
                "  作者：" + author  +
                "  价格：" + price +
                "  类型：" + type  +
                "  借阅状态：" + ((isBorrowed == true?"已被借阅":"未被借阅")) +
                '}';
    }
}
